<template>
	<view class="content">
		home页面
		<view @click="goTopage">测试路由配置跳转</view>
		<div>测试vant 以及div标签</div>
		<div>
			<div><span>span标签以及Img标签在小程序的渲染</span></div>
		</div>

		<van-button type="primary">主要按钮2</van-button>
		<van-button type="info">信息按钮</van-button>
		<van-button type="warnning">警告按钮</van-button>
		<van-button type="info" @click="testInterface">测试接口调取</van-button>
		<van-button type="info" @click="scanPdf">pdf预览:{{test}}</van-button>
		<!-- <div>分包图片测试1</div>
		<image src='/subPackages/home/static/images/video.png'></image> -->
	</view>
</template>

<script>
	import sm from 'sm-crypto'
	import moment from '@/wxcomponents/moment/moment.js'
	import request from '@/common/utils/request.js'
	import {
		testApi,
		login
	} from '@/common/api/api.js'
	export default {
		data() {
			return {
				title: 'Hello',
				test:'我的名字'
			};
		},
		created() {
			console.log(sm, '获取加密包', moment, '测试时间Moment控件', moment("20111031", "YYYYMMDD").fromNow())
			console.log(this.$router, '获取路由', this.$Router)
		},
		onLoad() {},
		methods: {
			goTopage() {
				console.log(this.$router, 111)
				// this.$router.push('/pages/login/index')
			},
			// 预览pdf
			scanPdf() {
				console.log('查看pdf')
				uni.openDocument({
				      filePath: '/static/pdf/test.pdf',
				      fileType: 'pdf',
				      success: function (res) {
				        console.log('打开文档成功');
				      },
				      fail: function (err) {
				        console.error('打开文档失败', err);
				      }
				    });
			},
			testInterface() {
				console.log(testApi, 1111, login)
				request({
					url: 'example/api/test',
					method: 'post',
					params: {
						id: 123,
					}
				}).then(() => {

				}).catch((err) => {
					console.log(err, '错误')

				})

				login({
					username: 'testuser', // 传入实际登录参数
					password: 'testpass'
				}).then((res) => {
					console.log('登录成功', res)
				}).catch((err) => {
					console.log(err, '登录错误')
				})
			},
		}
	};
</script>

<style>
	.content {
		text-align: center;
		height: 400upx;
		margin-top: 200upx;
	}
</style>